package com.zhanglijie.theory.balking;

import java.util.Scanner;

/**
 * @author zhanglijie
 * @version 1.0
 * @since 1.1.0 2022/8/11 0011 23:22
 */
public class DoctorThread extends Thread {
    private final String path;
    private final String name;
    private final Scanner scanner = new Scanner(System.in);

    public DoctorThread(String path, String name) {
        super("doctor thread");
        this.path = path;
        this.name = name;
    }

    @Override
    public void run() {
        try {
            int time = 0;
            Screan screan = Screan.create(path, name);
            while (true) {
                String next = scanner.next();
                screan.edit(next);
                if(time == 5){
                    screan.save();
                    time = 0;
                }
                time ++;
            }
        }catch (Exception e){}

    }
}
